package com.hopu.controller;

import com.hopu.entity.Result;
import com.hopu.entity.Video;
import com.hopu.entity.WorkLikeDTO;
import com.hopu.service.LikeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/like")
public class LikeController {

    @Autowired
    private LikeService likeService;

    /**
     * 点赞/取消点赞
     *
     * @param workLikeDTO
     * @return
     */
    @PostMapping
    public Result toggleLike(@RequestBody WorkLikeDTO workLikeDTO) {
        likeService.toggleLike(workLikeDTO);
        return Result.success();
    }

    /**
     * 查询点赞数
     *
     * @param video
     * @return
     */
    @PutMapping
    public Result updateLikeCount(@RequestBody Video video) {
        return Result.success(likeService.getLikeCount(video));
    }
}
